/**
 * 
 */
package com.ekingstar.framework.action;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.config.Action;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 
 * 
 */
@Action(name = "param", namespace = "/test")

public class ParamAction extends ActionSupport {
	private String userId;

	
	
	public String getUserId() {
		return userId;
	}
	private String fileFileName;


	public void setUserId(String userId) {
		this.userId = userId;
	}

	private File file;

	
	



	public String getFileFileName() {
		return fileFileName;
	}



	public void setFileFileName(String fileFileName) {
		this.fileFileName = fileFileName;
	}



	public File getFile() {
		return file;
	}



	public void setFile(File file) {
		this.file = file;
	}

	public String input(){
		PrintWriter out;
		try {
			ServletActionContext.getResponse().setContentType("text/html; charset=UTF-8");
			out = ServletActionContext.getResponse().getWriter();
			
			out.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'></head><body><form method='post' enctype='multipart/form-data' action='/hedss/test/param.action'><input type='file' name='file'/><input type='submit' value='提交'/></form></body</html>");
		} catch (IOException e) {
			// TODO Auto-generated catch block>
			e.printStackTrace();
		}
		
		return null;
	}

	public String execute(){
		PrintWriter out;
		try {
			out = ServletActionContext.getResponse().getWriter();
			out.print("userId:"+userId);
			System.out.println(userId);
			FileUtils.copyFile(file, new File("c:/bea/"+fileFileName));
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return null;
	}
}
